// swift 4.2+
let number = Int.random(in: 0..< 10)
let fraction = Float.random(in: 0 ..< 1)

let names = ["Ford", "Zaphod", "Trillian", "Arthur", "Marvin"]
let randomName = names.randomElement()

let names = ["Ford", "Zaphod", "Trillian", "Arthur", "Marvin"]
names.shuffle()

let sequence = 0 ..< 7
let shuffledSequence = sequence.shuffled()

// swift < 4.2
let n = Int(arc4random_uniform(42))

let d = drand48()  // Output: 0.396464773760275
print(d)  

func random(_ n:Int) -> Int  
{
    return Int(arc4random_uniform(UInt32(n)))  
}

let names = ["Arthur", "Ford", "Zaphod", "Marvin", "Trillian"]
let random = names[Int(arc4random_uniform(UInt32(names.count)))]  